const router = require('koa-router')()
const cabines = require('../controller/api/cabines')
const archives = require('../controller/archives')
const check = require('../controller/check')
const mssql =  require('../lib/mssql')
const setup  = require('../controller/setup')

router.prefix('/geek')

router.get('/:room/:area', async (ctx, next) => {
    console.log(ctx.params); 
    await ctx.render('index',{
        title: '我是首页',
        body: '我是内容啊',
        area: ctx.params['area'],
        room: ctx.params['room'],
    });
})



router.get('/:room/:area/ventilate', cabines.ventilate)
router.get('/:room/:area/areaColumnConfiguration', cabines.areaColumnConfiguration)
router.get('/:room/:area/initialStatus', cabines.initialStatus)
router.get('/:room/:area/heartbeats', cabines.heartbeats)
router.get('/:room/:area/open', cabines.open)
router.get('/:room/:area/close', cabines.close)
router.get('/:room/:area/stop', cabines.stop)
router.get('/:room/:area/setup', setup.get)
router.get('/:room/:area/setup', setup.get)
router.get('/:room/:area/setupTable', setup.get)
router.put('/:room/:area/setupTable', setup.put)
router.get('/:room/:area/archives/', archives.list)
router.get('/:room/:area/archives/query', archives.query)
router.post('/:room/:area/check/upload', check.upload)
router.get('/:room/:area/check/upload', check.upload)


router.get('/:room/:area/check/result', check.result)

router.get('/:room/:area/check/download', check.download)
router.get('/:room/:area/check', check.list)


router.get('/:room/:area/archives/preprocessed', archives.preprocessed)
router.get('/test/', cabines.test)


/*


router.get('/mssql', async (ctx, next) => {
   var sql = "SELECT TOP 10  from sys_Users  ORDER BY id DESC";
    mssql(sql, result => {

        console.log("================?");
        res.send(result);
    })
 
        console.log("================");

   await ctx.render('index',{
        title: '我是首页',
        body: '我是内容啊'
    });
})
router.get('/mssql', (req, res) => {
    var sql = "SELECT TOP 10  from user  ORDER BY id DESC";
    mssql(sql, result => {
        console.log(result);
        res.send(result);
    })

})
*/
 
/*
router.get('/find', controller.find)

router.post('/insert', controller.insert)

router.delete('/delete', controller.delete)

router.put('/update', controller.update)
*/
module.exports = router